@extends('layouts.admin')
@section('content')

<div class="result_content">
                <div class="short_wrap">
                    <a href="{{url('admin/cate/create')}}"><i class="fa fa-plus"></i>新增分类</a>
                </div>
</div>


        <div class="am-u-sm-12">
            
                <table style="padding-left:230px"  class="am-table am-table-compact am-table-striped tpl-table-black " id="example-r">
                    <tr>
                        <th>排序</th>
                        <th>ID</th>
                        <th>分类名称</th>
                        <th>分类标题</th>
                        <th>查看次数</th>
                        <th>操作</th>
                    </tr>
                    @foreach($data as $v)
                    <tr class="gradeX">
                        <td>
                            <input style="width:30px;" type="text" value="{{$v->cate_order}}" onchange="changeOrder(this,{{$v->cate_id}})">
                        </td>
                        <td class="tc">{{$v->cate_id}}</td>
                        <td>
                            <a href="#">{{$v->_cate_name}}</a>
                        </td>
                        <td>{{$v->cate_title}}</td>
                        <td>{{$v->cate_view}}</td>
                        <td>
                            {{--admin/user/1/edit--}}
                            <a href="{{url('admin/cate/'.$v->cate_id.'/edit')}}"><i class="am-icon-pencil"></i>修改</a>
                           <a href="javascript:;" class="tpl-table-black-operation-del" onclick="delCate({{$v->cate_id}})"><i class="am-icon-trash">删除</i></a>
                        </td>
                    </tr>
					
                @endforeach
                </table>

            
       </div>
    </form>

    <!--搜索结果页面 列表 结束-->

    <script>
        function changeOrder(obj,cate_id){
//            获取用户输入的排序号
             var cate_order = $(obj).val();

            $.post("{{url('admin/cate/changeorder')}}",{'_token':"{{csrf_token()}}",'cate_id':cate_id,'cate_order':cate_order},function(data){
                if(data.status == 0){
                    location.href = location.href;
                    layer.msg(data.msg, {icon: 6});
                }else{
                    location.href = location.href;
                    layer.msg(data.msg, {icon: 5});
                }
            });
        }
        function delCate(userid){
		
            //询问框
            layer.confirm('是否确认删除？', {
                btn: ['确定','取消'] //按钮
            }, function(){
                $.post("{{url('admin/cate/')}}/"+userid,{'_method':'delete','_token':"{{csrf_token()}}"},function(data){
                    if(data.status == 0){
                        location.href = location.href;
                        layer.msg(data.msg, {icon: 6});
                    }else{
                        location.href = location.href;
                        layer.msg(data.msg, {icon: 5});
                    }
                });
            }, function(){
            });
        }

    </script>
@endsection